import request from '@/utils/request'
import { QrCreate } from "@/types/login";
/**
 * 登录
 * @param params 
 * @returns 
 */
export const login = (params?: any) => {
  return request({
    url: '/login/cellphone',
    method: 'get',
    params,
    headers: {
      'content-type': 'application/json',
    }
  })
}

/**
 * 登出
 * @param params 
 * @returns 
 */
export const logout = () => {
  return request({
    url: '/logout',
    method: 'get',
  })
}

// 调用此接口可生成一个 key 用与生成二维码
export const getQrKey = (params?: any) => {
  return request({
    url: '/login/qr/key',
    method: 'get',
    params
  })
}
export const getQrcreate = (params: QrCreate) => {
  return request({
    url: '/login/qr/create',
    method: 'get',
    params
  })
}
// 二维码检测扫码状态接口
// 轮询此接口可获取二维码扫码状态,800 
// 为二维码过期,801 
// 为等待扫码,802 为待确认,
// 803 为授权登录成功(803 状态码下会返回 cookies)
export const getQrcheck = (params: QrCreate) => {
  return request({
    url: '/login/qr/check',
    method: 'get',
    params
  })
}